package com.mapull.date;

import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @author mapull
 */
public class MapullOffsetDate {

    public static void main(String[] args) {
//        print();
//        instantToString();
//        printInstant();
        printZoneDate();
    }

    private static void print(){
        System.out.println(new Date());
        System.out.println(OffsetDateTime.now());
    }

    private static void instantToString(){
        Instant instant = Instant.ofEpochMilli(1648828224030L);
        String string = instant.toString();
        System.out.println(string);
    }

    private static void printInstant(){
        String formatPattern = "yyyy-MM-dd";
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formatPattern);

        Instant instant = Instant.now();
        String date = formatter.format(instant);
        System.out.println("格式化前 " + instant);
        System.out.println("格式化后 " + date);
    }

    private static void printZoneDate(){
        LocalDateTime dateTime = LocalDateTime.now();
        ZonedDateTime zonedDateTime = ZonedDateTime.of(dateTime, ZoneId.of("Europe/Paris"));
        System.out.println("原始 " + dateTime);
        System.out.println("时区 " + zonedDateTime);
    }
}
